<!DOCTYPE html>
<html lang="zh">
	<head>
		<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<title>接收参数</title>
		<style type="text/css">
			html {
				height: 100%
			}

			body {
				height: 100%;
				margin: 0px;
				padding: 0px
			}

			#container {
				height: 100%
			}
		</style>
	</head>
	<body>
		<div id='container'></div>
	</body>
	<!-- 微信 JS-SDK 如果不需要兼容小程序，则无需引用此 JS 文件 -->
	<script type="text/javascript" src="https://res.wx.qq.com/open/js/jweixin-1.4.0.js"></script>

	<!-- uni 的 SDK -->
	<script type="text/javascript" src="https://js.cdn.aliyun.dcloud.net.cn/dev/uni-app/uni.webview.1.5.2.js"></script>

	<!-- 百度地图 -->
	
	<script type="text/javascript" src="https://api.map.baidu.com/api?v=1.0&type=webgl&ak=Af6FfpOOZrHT1Ff2enuUKMZgjz4NfQ3W"></script>
	
	<!-- 示例文档 -->
	<!-- https://lbsyun.baidu.com/index.php?title=jspopularGL/guide/show -->
	
	<script type="text/javascript">
		document.addEventListener('UniAppJSBridgeReady', function() {
			// 配置百度地图
			var map = new BMapGL.Map("container");   // 创建地图实例
			map.enableScrollWheelZoom(true);   // 开启鼠标滚轮缩放
			// 添加自定义图标
			function addCustomIcon(lng, lat) {
				var point = new BMapGL.Point(lng, lat);
				var myIcon = new BMapGL.Icon("./images/marker.png", new BMapGL.Size(40, 40), {
					// 指定定位位置
					anchor: new BMapGL.Size(18, 30),
				});
				// 创建标注对象并添加到地图  
				var marker = new BMapGL.Marker(point, {
					icon: myIcon,
					enableDragging: true,
					overlayType: 'iconMarker' // 自定义属性，用于特定删除
				});
				map.addOverlay(marker);
			}
			
			// 获取 url 参数
			function getQuery(name) {
				// 正则：[找寻'&' + 'url参数名字' = '值' + '&']（'&'可以不存在）
				let reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
				let r = window.location.search.substr(1).match(reg);
				if (r != null) {
					// 对参数值进行解码
					return decodeURIComponent(r[2]);
				}
				return null;
			}
			
			var uniParamPoint = getQuery('point');
			var pointArr = uniParamPoint.split(',')
			var pointLng = pointArr[0]
			var pointLat = pointArr[1]
			var alarmPoint = new BMapGL.Point(pointLng, pointLat); // 创建点坐标
			map.centerAndZoom(alarmPoint, 16);
			addCustomIcon(pointLng, pointLat)
		});
	</script>
</html>
